import java.lang.reflect.Array;
import java.util.Arrays;

public class shellSort {
    public static void shell(int[] arrays,int grap){
        for (int i = grap; i < arrays.length; i ++) {
            int j = i - grap;
            int temp = arrays[i];
            for (; j >= 0 ; j -= grap) {
                if(arrays[j] > temp){
                    arrays[j+grap] = arrays[j];
                }else{
                    break;
                }
            }
            arrays[j+grap] = temp;
        }
    }

    public static void shellSort(int[] arrays){
        int grap = arrays.length;
        while(grap > 1){
            grap /= 2;
            shell(arrays,grap);
        }
    }

    public static void testSellSort(int[] arrays){
        long start = System.currentTimeMillis();
        //System.out.println(Arrays.toString(arrays));
        shellSort(arrays);
        //System.out.println(Arrays.toString(arrays));
        long end = System.currentTimeMillis();

        System.out.println("希尔排序所花费的时间为：" + (end - start));
    }
    public static void main(String[] args) {
        int[] arrays = new int[100_0000];
        Public.func1(arrays);
        testSellSort(arrays);

        Public.func2(arrays);
        testSellSort(arrays);

        Public.func3(arrays);
        testSellSort(arrays);




    }
}
